#pragma once

#include <Game/Entity.h>
#include <Totem/Component.h>
#include <Totem/PropertyList.h>

namespace Game
{
	class EntityManager;

	namespace World
	{
		class Exit;
		namespace Systems { class RoomSystem; }
		namespace Components
		{
			class Room : public Totem::Component
			{
			public:
				COMPONENT_1(Entity, Room, Systems::RoomSystem);

				Room(Entity &owner, const T_String &type, Systems::RoomSystem &roomSystem);
				virtual ~Room();
				Entity &getOwner() { return owner; }
				
				Entity &create();

				virtual void update(const F32 &dt);

				Systems::RoomSystem &getSystem() { return roomSystem; }
				EntityManager &getEntityMgr() { return *entityMgr; }

			private:
				Systems::RoomSystem &roomSystem;
				EntityManager *entityMgr;

				Totem::PropertyList<Exit*> exits;
				Totem::PropertyList<Entity*> entities;

				T_HashedString enterEventId;
				T_HashedString leaveEventId;

				void onEnter(Entity &entity, const U32 &direction);
				void onLeave(Entity &entity, const U32 &direction);
			};
		}
	}
}
